home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / contributed / blitzbasic / bbcodefinder.vbs < prev    next >
Text File  |  2004-02-29  |  3KB  |  159 lines

  1. ' Blitz Basic CodeFinder by Peter Scheutz
  2. ' For Syn Edit (made in/for version 2.0.0.23)
  3. ' Public Domain 2002-09-07
  4. '
  5. ' USAGE: View -> Options - > Makro -> Add (select Codefinder.Vbs)
  6. ' "Check Create ToolBar Buttons For:"
  7. '
  8. ' Right Click the toolbar  Select "Customize"
  9. ' In the Keyboard Tab  Select -> Category - > Codefinder
  10. ' Assign a key (I use F2)
  11. '
  12. ' With a .bb File loaded, press the hot key.
  13. ' Single clicking will Select the Function/Type/Label
  14. ' Double clicking will Select the Function/Type/Label and close dialog.
  15. '
  16. ' Save this file as Codefinder.Vbs
  17.  
  18. Option Explicit
  19.  
  20. const mrOK       = 1
  21.  
  22. Dim codeList
  23. Dim btnOK, btnFunctions, btnTypes, btnLabels
  24.  
  25. Dim linesIndex()
  26. Dim form
  27.  
  28. Sub ListClick(Sender)
  29.   Dim sel
  30.   sel = Sender.Items(Sender.ItemIndex)
  31.   ActiveDocument.HighlightLine linesIndex(Sender.ItemIndex), 1, 0
  32.  
  33. End Sub
  34.  
  35. Sub ListDblClick(Sender)
  36.   Dim sel
  37.   sel = Sender.Items(Sender.ItemIndex)
  38.   ActiveDocument.HighlightLine linesIndex(Sender.ItemIndex), 1, 0
  39.   btnOK.Click
  40. End Sub
  41.  
  42.  
  43. Sub ListLines(ls)
  44.   Dim i, l, p
  45.   Dim funcstr
  46.   Dim count
  47.   ReDim linesIndex(2000)
  48.  
  49.   While codeList.Items.count > 0
  50.     codeList.Items.Delete (0)
  51.   Wend
  52.  
  53.   With codeList
  54.     .Parent = form
  55.     .Left = 2
  56.     .Top = 2 + 20
  57.     .Width = .Parent.Width - 10
  58.     .Height = .Parent.Height - 44
  59.  
  60.     .OnClick = "ListClick"
  61.     .OnDblClick = "ListDblClick"
  62.   End With
  63.  
  64.   Set l = ActiveDocument.Lines
  65.   For i = 0 To l.count - 1
  66.     If Trim(UCase(Left(l(i), Len(ls)))) = ls Then
  67.       p = InStr(UCase(l(i)), ls)
  68.  
  69.       If ls <> "." Then p = InStr(p + 1, l(i), " ")
  70.       If p Then
  71.         funcstr = Right(l(i), Len(l(i)) - p)
  72.         codeList.Items.Add funcstr
  73.         If i < 2000 Then linesIndex(count) = i + 1
  74.         count = count + 1
  75.  
  76.       End If
  77.     End If
  78.   Next
  79.   ReDim Preserve linesIndex(count)
  80.  
  81. End Sub
  82.  
  83.  
  84. Sub EditChange(Sender)
  85.   If Sender.Caption = "Functions" Then ListLines "FUNCTION"
  86.   If Sender.Caption = "Types" Then ListLines "TYPE"
  87.   If Sender.Caption = "Labels" Then ListLines "."
  88. End Sub
  89.  
  90.  
  91. Sub Main(dummy)
  92.   If Documents.count = 0 Then
  93.     MsgBox "No Document open.", vbCritical
  94.     Exit Sub
  95.   End If
  96.  
  97.   form = Create("TForm", Self)
  98.   With form
  99.     .Caption = "Blitz Code Finder"
  100.     .Position = "poOwnerFormCenter"
  101.     .BorderStyle = "bsDialog"
  102.     .Width = 380
  103.     .Height = 400
  104.   End With
  105.  
  106.  
  107.   btnFunctions = Create("TButton", form)
  108.   With btnFunctions
  109.     .Parent = form
  110.     .Top = 2
  111.     .Caption = "Functions"
  112.     .Left = 2
  113.     .Height = 20
  114.     .Width = 70
  115.     .OnClick = "EditChange"
  116.   End With
  117.  
  118.   btnTypes = Create("TButton", form)
  119.   With btnTypes
  120.     .Parent = form
  121.     .Top = 2
  122.     .Caption = "Types"
  123.     .Left = 2 + 74
  124.     .Height = 20
  125.     .Width = 70
  126.     .OnClick = "EditChange"
  127.   End With
  128.  
  129.   btnLabels = Create("TButton", form)
  130.   With btnLabels
  131.     .Parent = form
  132.     .Top = 2
  133.     .Caption = "Labels"
  134.     .Left = 2 + 74 + 74
  135.     .Height = 20
  136.     .Width = 70
  137.     .OnClick = "EditChange"
  138.   End With
  139.  
  140.  
  141.   btnOK = Create("TButton", form)
  142.   With btnOK
  143.     .Parent = form
  144.     .Top = 65
  145.     .Caption = "OK"
  146.     .Left = 46
  147.     .Default = True
  148.     .ModalResult = mrOK
  149.   End With
  150.  
  151.  
  152.   codeList = Create("TListBox", form)
  153.   codeList.Parent = form
  154.   ListLines "FUNCTION"
  155.  
  156.   form.ShowModal
  157.   form.Free
  158. End Sub
  159.